package fi.solita.dojo.mazeserver

import java.net._
import scala.actors._
import scala.actors.Actor._
import swing._
import game._
import map._
import ui._
import client._
import javax.swing._

object Server extends SimpleGUIApplication { 

	GameActor.start  
	ClientService.start  
  
override def main(args: Array[String]) = {
    super.main(args) // TODO remove super
 
  	val listener = new Thread(new ListenThread())
	listener.start()
  } 
 
	def top = new MainFrame {
		title = "GameServer"
		contents = ServerUI
	}
}

class ListenThread extends Runnable {
	def run() {
		val port = 12111
		val serverSocket = new ServerSocket(port)

		println("Listening to " + port)
		while(true) {
			val socket = serverSocket.accept()
			ClientService ! Connect(socket)
		}
	}
}



